
//
//  LeeSetFunctionViewController.m
//  EcologyME
//
//  Created by 李雪虎 on 2017/8/9.
//  Copyright © 2017年 xzcysoft. All rights reserved.
//

#import "LeeSetFunctionViewController.h"
#import "LeeshezhiTableViewCell.h"
#import "NOPayPasswordViewController.h"//支付密码
#import "BinDingAliPayViewController.h"//支付宝
#import "BankCardBinDingViewController.h"//银行卡
#import "BindingWeChatViewController.h"//微信
#import "LeePhonoNumberViewController.h"//手机
#import "BindingPhoneViewController.h"//手机
@interface LeeSetFunctionViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *tabelView;//表
@property(nonatomic,strong)UIView *BigView;//表头View
@property(nonatomic,strong)UILabel *nameLabel;//姓名
@property(nonatomic,strong)NSArray *titleARR;
@property(nonatomic,strong)NSArray *imgArr;
@end

@implementation LeeSetFunctionViewController
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden=NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置";
    self.view.backgroundColor = COLOR(229, 230, 231, 1);
    _titleARR = @[@[@"修改支付密码",@"修改登录密码",@"绑定手机",@"绑定微信",@"绑定支付宝",@"绑定银行卡"],@[@"帮助说明",@"关于元点"]];
    _imgArr =@[@[@"grzxcz",@"grzxszmm",@"shdbdsj",@"shdbdwx",@"shdbdzfb",@"shdbdyhk"],@[@"xxgrzxbzsm",@"xxgrzxgyyd-1"]];
    [self addTabelView];//
    // Do any additional setup after loading the view.
}
-(void)addTabelView{
    //表格
    _BigView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, width_screen, 200)];
    _BigView.backgroundColor = [UIColor greenColor];
    UIImageView *ingView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, width_screen, 200)];
    ingView.image = [UIImage imageNamed:@"shdtjbg"];
    ingView.userInteractionEnabled=YES;
    [_BigView addSubview:ingView];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 150, width_screen, 50)];
    label.text = @"小铺李四";
    label.font = [UIFont systemFontOfSize:21];
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.5f];
    [_BigView addSubview:label];
    
    _tabelView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, width_screen, height_screen-64) style:UITableViewStyleGrouped];
    _tabelView.backgroundColor = [UIColor clearColor];
    _tabelView.tableHeaderView = _BigView;
    _tabelView.showsVerticalScrollIndicator = NO;//隐藏滑动条
    _tabelView.separatorColor = COLOR(229, 230, 231, 1);//分割线颜色
    _tabelView.delegate = self;
    _tabelView.dataSource = self;
    _tabelView.bounces = NO;//禁止tableView弹性效果
    [_tabelView registerNib:[UINib nibWithNibName:@"LeeshezhiTableViewCell" bundle:nil] forCellReuseIdentifier:@"OenCell"];
    [self.view addSubview:_tabelView];
}
#pragma mark --tableView 代理方法
//区头高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 15;
}
//cell高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}
//多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section==0) {
        return 6;
    }else{
        
        return 2;
    }
}
//几个区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
//区尾高度
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    
    if (section==0) {
        return 0.001;
    }else{
        return 70;
    }
}
//区尾视图
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view;
    if (section==1) {
        view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, width_screen, 80)];
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(10, 10, width_screen-20, 60)];
        button.backgroundColor = [UIColor redColor];
        button.titleLabel.font = [UIFont systemFontOfSize:20];
        //按钮编辑
        [button.layer setMasksToBounds:YES];
        //边框圆角半径
        [button.layer setCornerRadius:5.0];
        [button setTitle:@"退出登录" forState:UIControlStateNormal];
        
        [view addSubview:button];
    }
        return view;
    
}
//cell内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    LeeshezhiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OenCell"];
    cell.titleLabel.text = _titleARR[indexPath.section][indexPath.row];
    cell.imgView.image = [UIImage imageNamed:_imgArr[indexPath.section][indexPath.row]];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section==0) {
        if (indexPath.row==0) {
            //修改支付密码
            [self.navigationController pushViewController:[NOPayPasswordViewController new] animated:YES];
        }else if (indexPath.row==1){
            //修改登录密码
            [self.navigationController pushViewController:[NOPayPasswordViewController new] animated:YES];
        }else if (indexPath.row==2){
            //绑定手机
            [self.navigationController pushViewController:[BindingPhoneViewController new] animated:YES];
        }else if (indexPath.row==3){
            //绑定微信
            [self.navigationController pushViewController:[BindingWeChatViewController new] animated:YES];
        }else if (indexPath.row==4){
            //绑定支付宝
            [self.navigationController pushViewController:[BinDingAliPayViewController new] animated:YES];
        }else if (indexPath.row==5){
            //绑定银行卡
            [self.navigationController pushViewController:[BankCardBinDingViewController new] animated:YES];
        }
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
